import request from '@/utils/request';

// 查询数据接口
export async function getBatchProductByPage(params: any) {
  return request('/api/project/getBatchProductByPage', {
    method: 'POST',
    data: params,
  });
}

export async function getBatchProductDesign(params: any) {
  return request('/api/project/getBatchProductDesign', {
    method: 'POST',
    data: params,
  });
}

export async function addBatchProduct(params: any) {
  return request('/api/project/addBatchProduct', {
    method: 'POST',
    data: params,
  });
}

export async function updateBatchProduct(params: any) {
  return request('/api/project/updateBatchProduct', {
    method: 'POST',
    data: params,
  });
}

export async function delBatchProduct(params: any) {
  return request('/api/project/delBatchProduct', {
    method: 'POST',
    data: params,
  });
}

export async function exportBatchProduct(params: any) {
  return request('/api/project/exportBatchProduct', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

// 确认审核
export async function confirmDesignReview(para: any) {
  return request('/api/design/confirmDesignReview', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    params: {
      batchProductId: para.batchProductId,
      reviewState: para.reviewState,
      // userId: para.userId,
      reviewMemo: para.reviewMemo,
    },
  });
}

// 批量审核
export async function batchConfirmDesignReview(para: any) {
  return request('/api/project/batchConfirmDesignReview', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    params: {
      batchProductId: para.batchProductId,
      reviewState: para.reviewState,
      // userId: para.userId,
      reviewMemo: para.reviewMemo,
    },
  });
}

//下发工单
export async function issueWorkOrderInforByPage(params: any) {
  return request('/api/product/issueWorkOrderInforByPage', {
    method: 'POST',
    data: params,
  });
}

export async function getBopCodeAndName(params: any) {
  return request('/api/design/getBopCodeAndName', {
    method: 'POST',
  });
}

// 设置工艺路径
export async function setBop(para: any) {
  return request('/api/design/setBop', {
    method: 'POST',
    params: {
      unStandTypeId: para.unStandTypeId,
      bopCode: para.bopCode,
    },
  });
}

// 提交审核
export async function commitDesignReview(para: any) {
  return request('/api/project/commitDesignReview', {
    method: 'POST',
    data: para,
    params: {
      batchProductId: para.batchProductId,
    },
  });
}
// export async function confirmDesignReview1(para: any) {
//   return request('/api/design/confirmDesignReview', {
//     method: 'POST',
//     data: para,
//     params: {
//       batchProductId: para.id,
//       reviewState: para.state,
//     },
//   });
// }

// 工艺路径是否修改
export async function getBop(para: any) {
  return request('/api/design/getBop', {
    method: 'POST',
    data: para,
    params: {
      unStandTypeId: para.unStandTypeId,
    },
  });
}

// 工时周期
export async function getUnStandProductProcessInfoByUnstandTypeId(para: any) {
  return request('/api/design/getUnStandProductProcessInfoByUnstandTypeId', {
    method: 'POST',
    params: {
      unStandTypeId: para.unStandTypeId,
    },
  });
}

// 排程页查看工时周期
export async function getPagedProductProcessInfoByProductId(params: any){
  return request('/api/design/getPagedProductProcessInfoByProductId',{
    method:'POST',
    data:params,
  })
}

// 设置工时+周期
export async function addUnStandProductProcessInfo(params: any) {
  return request('/api/design/addUnStandProductProcessInfo', {
    method: 'POST',
    data: params,
  });
}

// 导出工时模板
export async function exportWorkhourAndCycle(para: any) {
  return request('/api/design/exportWorkhourAndCycle', {
    method: 'POST',
    params: {
      projectCode: para.projectCode,
      projectInfoId: para.projectInfoId,
      projectName: para.projectName,
    },
    responseType: 'blob',
  });
}

//工时模板下载
export async function exportWorkhourAndCycleByProductId(para: any) {
  return request('/api/design/exportWorkhourAndCycleByProductId', {
    method: 'POST',
    data: para,
    responseType: 'blob',
  });
}

// 工时上传
export async function uploadWorkhourAndCycle(para: any) {
  return request('/api/design/uploadWorkhourAndCycle', {
    method: 'POST',
    requestType: 'form',
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    data: para.file,
  });
}

export default {
  getBatchProductByPage,
  addBatchProduct,
  updateBatchProduct,
  delBatchProduct,
  exportBatchProduct,
  commitDesignReview,
  exportWorkhourAndCycleByProductId,
};
